1. Field of the Invention
The invention relates to a system for compressing a halftone image and a method therefor.
2. Related Art
In a terminal printer or the like of a computer system, when a binary image such as a character or a line drawing is to be printed, the image is represented by a normal dot matrix having the same vertical and horizontal resolutions, for example, 300 dpi vertical.times.300 dpi horizontal. Hereinafter, an image represented by a normal dot matrix is referred to as "normal image".
In contrast, when an image such as a photograph having a halftone is to be printed, the image is represented by a dot matrix of, for example, 300 dpi vertical.times.1,200 dpi horizontal, in which the horizontal (or vertical) resolution is greater than that of a normal dot matrix by the factor of N (in the example, fourfold). Hereinafter, an image having a resolution in one direction which is greater by the factor of N than that of a normal image is referred to as "N-fold density image". When an N-fold density image is used, a halftone can be represented by a black and white pattern in which N dots are formed in one pixel.
In the case where an N-fold density image is to be stored, a memory capacity which is greater by N times than that required for storing a normal image is required when the N-fold density image is stored as it is. When compression coding is done, it is possible to store such an image in a memory of a smaller capacity. In a basic, known compression coding method, one pixel represented by N dots is allocated a compression code having a number of bits in which all dot patterns that can be produced by N dots can be represented.
In the case of the above-mentioned 4-fold density image, for example, the number of possible dot patterns which can be produced by one pixel is 8 in total, i.e., two patterns in which all dots of the pixel are only white or only black, three patterns in which one, two, or three black dots are arranged with starting from the right end, and three patterns in which one, two, or three black dots are arranged with starting from the left end. Consequently, it is possible to use a 3-bit code as a compression code so that a required memory capacity is reduced to be only three times as much as that required for storing a normal image.
In another known method, compression coding is conducted in the following manner in order to attain a higher compression ratio. Two pixels which are horizontally adjacent to each other are set as a unit, and a fixed limitation is imposed on dot patterns which can be produced by the two pixels. Under this limitation, a compression code of a bit number by which all dot patterns that can be produced by two pixels can be represented is allocated. The limitation of the dot patterns is that there is one or less black and white change in the area of two pixels, or that the black and white pattern in the area of two pixels is always "white", "black", "white and black", or "black and white" so that two or more black and white changes such as "white, black, and white" or "black, white, and black" are not permitted.
In the case of a 4-fold density image, for example, according to this method, the number of possible kinds of dot patterns which can be produced by two pixels is 16 in total, i.e., two patterns in which all dots of the whole of the 2-pixel area are white or black, seven patterns in which black dots in the number of one of 1 to 7 are arranged with starting from the right end, and seven patterns in which black dots in the number of one of 1 to 7 are arranged with starting from the left end. Consequently, it is possible to use a 4-bit code as a compression code for each two pixels so that a required memory capacity is reduced to be two times as that required for storing a normal image.
The latter method of compression coding will be described more generally. The above-mentioned limitation for a dot pattern is imposed on an N-fold density image so that the number of possible kinds of the black and white patterns which can be produced by a 2-pixel area is limited to Under this limitation, two pixels are represented by an M-bit compression code which satisfies the relationship of EQU 4N=2.sup.M.
This enables an N-fold density image to be stored in a memory of a capacity which is M/2 times as that required for storing a normal image.
In the case where an N-fold density image is to be merely stored, the latter prior art method of compression coding is effective. In the case where an N-fold density image is to be edited or processed, however, there arises a problem in that, when compression codes remain as they are, it is impossible to edit or process them.
In an editing process in which a positive photograph is inverted to a negative one, or characters are superposed on a photograph, for example, a NOT logical operation is conducted on an N-fold density image of the photograph, or an AND, OR, or XOR logical operation is conducted on an N-fold density image of the photograph and a normal image of the characters. When these logical operations are observed in the view point of the action of an N-fold density image on black and white patterns of pixels, the NOT operation means that black and white patterns of all pixels are inverted. The AND, OR, or XOR operation between an N-fold density image and a normal image (all dots of each pixel are black or white) is equivalent to the case where the black and white pattern of each pixel is converted into a pattern of all white dots or all black dots.
In a conventional compression code as described above, one M-bit code is provided for each two pixels. When one of the logical operations is conducted on such a compression code, the above-mentioned inversion or conversion is conducted on the portion of the compression code which portion corresponds to one of the pixels (i.e., the upper M/2-bit portion or the lower M/2-bit portion). However, the inversion or conversion conducted on a compression code does not always mean the same inversion or conversion as that which is to be conducted the black and white pattern of the pixel indicated by the compression code, or rather, often means conversion which is entirely different in content from the inversion or conversion to be conducted on the black and white pattern of the pixel.
As described above, when an editing process is conducted on a conventional compression code of an N-fold density image, it results in that a process which is entirely different from the intention of the editing process to have been conducted on black and white patterns of pixels before compression. Conventionally, therefore, an editing process of an N-fold density image is conducted in the following manner. First, compression codes are once returned to an original N-fold density image, and the editing process is conducted on the original N-fold density image. Thereafter, the resulting image is again converted into compression codes, and the compression codes are stored. This countermeasure also requires a memory of a capacity which is N times as that required for storing a normal image. Consequently, the merit of compression coding cannot fully be utilized.